{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "UnicodeEncodeError",
     "evalue": "'latin-1' codec can't encode characters in position 4-6: ordinal not in range(256)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mUnicodeEncodeError\u001b[0m                        Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-44-019188239442>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0mhe\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'asd,网，啊'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mhe\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'latin-1'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      6\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhe\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msavetxt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'np.csv'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mfmt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'%.2f'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdelimiter\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m','\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mheader\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mhe\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mUnicodeEncodeError\u001b[0m: 'latin-1' codec can't encode characters in position 4-6: ordinal not in range(256)"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "a = np.random.randn(3,3)\n",
    "he = 'asd,网，啊'\n",
    "he.encode('latin-1')\n",
    "print(he)\n",
    "np.savetxt('np.csv',a,fmt='%.2f',delimiter=',',header=he)\n",
    "df = pd.DataFrame(a)\n",
    "#df.to_csv('pd1.csv',header='益肾,养血,活血,调冲,运脾,养阴,安胎,调理,疏理,助孕,养心,扶正,温里,化湿,解郁,通络,调经,化痰,补肾,消癥,清湿,试孕,养肝肾,滋肾,清肝,和中,清心,生新,防拖,固冲,生乳,调理气血,杀胚,观察,滋肝肾,益气,清邪,固肾,腰酸,腹隐痛,腹吊痛,盆腔炎,便秘,出血,小腹压痛,子宫肌瘤,漏红,鼻塞,咽痒,感冒,便软,腰骶部痛,外感,便次增,干呕,咽痛,梦多,少量赤带,腹胀,痛经,腺肌症,无痛经,乳胀痛,乏力,面部痤疮,易汗出,潮热,怕冷,乳房胀痛,腹痛,寐欠安,脘胀,FSH高,眩晕,腹胀痛,胸痛,胸闷,皮肤瘙痒,口干,夜寐不佳,喉中痰有,息肉,夜寐欠安,便不畅,便畅,便欠畅,乏力易倦,头胀,纳欠佳,寐差,纳便可,内异症,耳鸣,恶心,便溏,尿量,咽痛')\n",
    "file_object = open('类别一丁珊珊 33 ET术后.txt')\n",
    "\n",
    "for line in file_object.readlines():\n",
    "    print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   Unnamed: 0         0         1         2         3         4         5  \\\n",
      "0           0  0.035999  1.598443 -0.843332 -1.952602  2.028234 -1.100431   \n",
      "1           1 -0.259350  0.109370  0.422450  1.069984 -0.123720 -0.452878   \n",
      "2           2 -0.688334  1.301578 -1.088172 -2.283423  0.906960  1.397491   \n",
      "\n",
      "          6         7         8    ...           87        88        89  \\\n",
      "0  0.261258  0.348827  0.126312    ...     0.662157  1.524267 -1.051879   \n",
      "1  0.709511  1.610453 -1.279334    ...     0.125516 -1.543714 -0.250104   \n",
      "2  0.395021  0.439787  0.476956    ...     0.136813  0.682190  0.210583   \n",
      "\n",
      "         90        91        92        93        94        95        96  \n",
      "0  0.385738 -0.899210  0.791411 -1.616837  0.794693  0.412200 -0.534047  \n",
      "1  1.360337 -1.223510  1.187883  2.037479 -0.139974  0.343466  0.553885  \n",
      "2 -1.319590 -0.820714 -0.693140  0.854800  0.704117 -0.441855 -2.350838  \n",
      "\n",
      "[3 rows x 98 columns]\n",
      "Index(['0', '1', '2'], dtype='object')\n",
      "          0         1         2\n",
      "0  0.035999  1.598443 -0.843332\n",
      "1 -0.259350  0.109370  0.422450\n",
      "   0  1  2\n",
      "2  1  2  1\n",
      "          0         1         2\n",
      "0  0.035999  1.598443 -0.843332\n",
      "1 -0.259350  0.109370  0.422450\n",
      "2  1.000000  2.000000  1.000000\n",
      "丁珊珊 33 ET术后 2009-6-19   首诊      13957629933\n",
      "\n",
      "今ET二枚。在用黄体酮60mg ，安琪2片。异位妊娠史，双T切除。纳便可\n",
      "\n",
      "舌红苔薄脉细，益肾养血观察\n",
      "\n",
      "熟地15 杞子12 归身9 炒白芍10 菟丝子20 阿胶珠10 紫河车6 橘皮络5 川芎5 党参15 生芪15 太子参15 桑寄生15 炒杜仲15    12   蛤士膜10g\n",
      "\n",
      "asd\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df = pd.read_csv('pd.csv',header=0,encoding='utf-8')\n",
    "print(df)\n",
    "#print(df.columns)\n",
    "df2 = df.iloc[0:2,1:4]\n",
    "print(df2.columns)\n",
    "print(df2)\n",
    "datanumpy = np.array([(1,2,1)])\n",
    "df3 = pd.DataFrame(datanumpy,index=[2],columns=df2.columns)\n",
    "print(df3)\n",
    "df4 = pd.concat([df2,df3])\n",
    "print(df4)\n",
    "#df4.to_csv('np.csv')\n",
    "\n",
    "file_object = open('类别一丁珊珊 33 ET术后.txt')\n",
    "\n",
    "for line in file_object.readlines():\n",
    "    if line == '\\n':\n",
    "        print('asd')\n",
    "        break\n",
    "    print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Empty DataFrame\n",
      "Columns: [益肾, 养血, 活血, 调冲, 运脾, 养阴, 安胎, 调理, 疏理, 助孕, 养心, 扶正, 温里, 化湿, 解郁, 通络, 调经, 化痰, 补肾, 消癥, 清湿, 试孕, 养肝肾, 滋肾, 清肝, 和中, 清心, 生新, 防拖, 固冲, 生乳, 调理气血, 杀胚, 观察, 滋肝肾, 益气, 固肾, 清邪, 腰酸, 腹隐痛, 腹吊痛, 盆腔炎, 便秘, 阴道出血, 小腹压痛, 子宫肌瘤, 漏红, 鼻塞, 咽痒, 感冒, 便软, 腰骶部痛, 外感, 便次增, 干呕, 咽痛, 梦多, 少量赤带, 腹胀, 痛经, 腺肌症, 无痛经, 乳胀痛, 乏力, 面部痤疮, 易汗出, 潮热 , 怕冷, 乳房胀痛, 腹痛, 寐欠安, 脘胀 , FSH高, 眩晕, 腹胀痛, 胸痛, 胸闷, 皮肤瘙痒, 口干, 夜寐不佳, 喉中痰有, 息肉, 夜寐欠安, 便不畅   , 便畅, 便欠畅, 乏力易倦, 头胀, 纳欠佳, 寐差, 纳便可, 内异症, 耳鸣, 恶心, 便溏, 尿量多]\n",
      "Index: []\n",
      "\n",
      "[0 rows x 96 columns]\n",
      "纳便可\n",
      "益肾\n",
      "养血\n",
      "观察\n",
      "asd\n",
      "漏红\n",
      "益肾\n",
      "养血\n",
      "安胎\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df = pd.read_csv('shuju1.csv',header=0,encoding='utf-8')\n",
    "print(df)\n",
    "#print(df.columns[2])\n",
    "file_object = open('类别一丁珊珊 33 ET术后.txt')\n",
    "\n",
    "for line in file_object.readlines():\n",
    "    for attr in df.columns:\n",
    "        if line == '\\n':\n",
    "            print('asd')\n",
    "            break\n",
    "        if attr in line:print(attr)\n",
    "    #print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
